package com.heying.springcore.aop.anno;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

//观众
@Component
@Aspect
public class Audience {

    @Pointcut("execution (* com.heying.springcore.aop.anno.Performer.perform(..))")
    public void perform(){

    }

    @Before("perform()")
    public void  takeSeat(){
        System.out.println("观众入席");
    }

    @Before("perform()")
    public void  turnOffPhone(){
        System.out.println("观众关机");
    }

    @AfterReturning("perform()")
    public void  applaud(){
        System.out.println("观众鼓掌");
    }

    @AfterThrowing("perform()")
    public void  throwEggs(){
        System.out.println("观众扔鸡蛋");
    }

    @Around("perform()")
    public void arround(ProceedingJoinPoint joinpoint) throws Throwable {
        System.out.println("观众入场");
        joinpoint.proceed();
        System.out.println("观众退场");
    }

}
